/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 */
package com.apache.order.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.manager.ProxyManager;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.cache.util.Validator;
import com.apache.order.entity.TOrder;
import com.apache.order.util.MessageUtil;

/**
 * description:  订单信息删除 
 * @author Hou Dayu 创建时间：2015-8-10  
 */
public class OrderInfoDelPluginImpl implements PluginConnector {

	private ProxyManager<TOrder> orderProxyManager;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.dwusoft.api.manager.PluginConnector#execute(com.dwusoft.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo arg0) throws Exception {
		String orderId = String.valueOf(arg0.getParams("orderId"));
		ResultEntity entity = new ResultEntity();
		entity.setResult("true");
		if (Validator.isNull(orderId)) {
			entity.setMessage(MessageUtil.getMessage("order-engine-0005", new String[0], "执行方法缺少必要参数"));
		}
		entity.setResult("true");
		String userName = String.valueOf(arg0.getParams("userName"));
		ParamsVo vo = new ParamsVo();
		vo.setInfoId(orderId);
		vo.setParams("orderId", orderId);
		vo.setParams("logUserEname", userName);
		vo.setKey("delOrder");
		String id = String.valueOf(orderProxyManager.saveInvoke(vo));
		if ("true".equals(id)) {
			entity.setEntity(id);
			entity.setMessage(MessageUtil.getMessage("order-engine-0014", new String[0], "订单信息保存成功"));
			arg0.setParams("orderId", id);
			OrderEnginePluginUtil.newFixed().saveLogMessage(arg0);
		} else {
			entity.setMessage(MessageUtil.getMessage("order-engine-0015", new String[0], "订单信息保存失败"));
		}
		return entity;
	}

	public void setOrderProxyManager(ProxyManager orderProxyManager) {
		this.orderProxyManager = orderProxyManager;
	}

}
